<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <script>
      function func1() {
        alert("hello");
      }

      function func2() {
        var res = window.prompt("hello，请输入姓名");
        console.log(res);
      }

      function func3() {
        var res = window.confirm("确认吗");
        console.log(res);
      }
      function func4() {
        window.setTimeout(function () {
          console.log("hello");
        }, 2000);
      }
      function funcA() {
        // 向前翻页
        history.back();
      }
      function funcB() {
        // 向后翻页
        history.forward();
      }
      function funcC() {
        // 修改地址栏中的 url
        location.href = "https://www.baidu.com"; 
      }
      function funD() {
        // 向 sessionStorage 存储数据
        sessionStorage.setItem("keyA","valueA");
        // 向 localStorage 存储数据
        localStorage.setItem("keyB","valueB");
      }
      function funE() {
        console.log(sessionStorage.getItem("keyA"));
        console.log(localStorage.getItem("keyB"));
      }
      function funF() {
        sessionStorage.removeItem("keyA");
        localStorage.removeItem("keyB");
      }
    </script>
  </head>
  <body>
    <button onclick = "funE()">读取数据</button>
    <button onclick = "funF()">清空数据</button>
    <button onclick = "funD()">存储数据</button>
    <hr/>
    <button onclick="funcC()">跳转百度</button>
    <hr />
    <button onclick="funcA()">上一页</button>
    <button onclick="funcB()">下一页</button>
    <hr />
    <button onclick="func1()">信息提示框</button>
    <button onclick="func2()">信息输入框</button>
    <button onclick="func3()">信息确认框</button>
    <button onclick="func4()">两秒钟后向控制台打印hello</button>
  </body>
</html>
